package com.yztc.orangeentertainment.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.yztc.orangeentertainment.R;
import com.yztc.orangeentertainment.bean.channalarticlecomment.ArticleCommentFirstListBean;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by My on 2016/10/10.
 */
public class ChannalArticleCommentAdapter extends RecyclerView.Adapter<ChannalArticleCommentAdapter
        .MyViewHolder> {
    private Context context;
    private List<ArticleCommentFirstListBean> commentList;

    public ChannalArticleCommentAdapter(Context context, List<ArticleCommentFirstListBean> commentList) {
        this.context = context;
        this.commentList = commentList;
    }


    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(context).inflate(R.layout
                .channalarticlecomment_item, parent, false);

        return new MyViewHolder(view);

    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.tvArticlecommentnum.setText(commentList.get(position).getDigg() + "");
        holder.tvArticlecommentusername.setText(commentList.get(position).getUser().getName());
        holder.ivArticlecommentphoto.setImageURI(commentList.get(position).getUser().getAvatar());
        holder.tvArticlecommenttime.setText(commentList.get(position).getPublish_time());
        holder.tvArticlecommentcontentsom.setText(commentList.get(position).getContent() );
    }

    @Override
    public int getItemCount() {
        return commentList.size();
    }

    static class MyViewHolder extends RecyclerView.ViewHolder {
        @InjectView(R.id.iv_articlecommentphoto)
        SimpleDraweeView ivArticlecommentphoto;
        @InjectView(R.id.tv_articlecommentusername)
        TextView tvArticlecommentusername;
        @InjectView(R.id.tv_articlecommenttime)
        TextView tvArticlecommenttime;
        @InjectView(R.id.tv_articlecommentcontentsom)
        TextView tvArticlecommentcontentsom;
        @InjectView(R.id.tv_articlecommentnum)
        TextView tvArticlecommentnum;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.inject(this, itemView);
        }
    }

}
